
#include <pic18.h>
//nclude "RF12B.h"
#include "SysClock.h"
#include "my_macros.h"
#include "App.h"
//nclude "Outputs.h"
#include "atd.h"
//nclude "Command.h"
#include "UART.h"
#include "printf.h"
#include "dbg.h"

//__CONFIG(FCMDIS & MCLRDIS & WDTDIS & BORDIS & UNPROTECT & PWRTEN & INTIO);
//  __CONFIG(FCMDIS & DEBUGDIS & BORV21 & LVPDIS & MCLRDIS & WDTDIS & BORDIS & UNPROTECT & PWRTEN & INTIO);

void init_device(void);

__CONFIG(1, IESODIS & FCMDIS & RCIO);
__CONFIG(2, BORV27 & BOREN & PWRTEN & WDTDIS & WDTPS32K);
__CONFIG(3, MCLRDIS & HFSTART & LPT1DIS & PBDIGITAL & CCP2RC1);
__CONFIG(4, DEBUGDIS & XINSTDIS & LVPDIS & STVREN);

unsigned long gcnt;


void main ( void )
{
	init_device();
	
//	for(;;);

	dbg("\n\r---------------------------------------------------------"); //Dima	
	for( ;;)
	{
		SysTime();
//		Drive_RF();
//		Inp_Drive();
//		uart_drive();
		
		ainp_drive();  

		
		if(app)app();

		gcnt++;
		if ( Time_5000ms )
		{
			dbg("\n\r==== mloopt: %luS", 5000000/gcnt); //Dima
			gcnt = 0;
		}

		/* if ( ComProc != NULL ) */
		/* { */
		/* 	ComProc(); */
		/* } */

//		Out_Drive();

//		CheckForLearn();
		
//		debug();
		
/* 		if ( Time_500ms ) */
/* 		{ */
/* 			DBG("\nTime_500ms\n"); */
/* 		} */
	}
}


